<template>
	<view class="addu">
		<view class="black_1">
			<view class="text1">姓名</view>
			<uni-easyinput
			v-model="name"
			  :input-border="false" 
			  placeholder="请输入姓名"
			  placeholder-style="font-size: 25rpx;color: #333333;" />
		</view>
		<view class="black_1">
			<view class="text1">微信</view>
			<uni-easyinput
				v-model="wx"
			  :input-border="false" 
			  placeholder="请输入微信"
			  placeholder-style="font-size: 25rpx;color: #333333;" />
		</view>
		<view class="black_1">
			<view class="text1">QQ</view>
			<uni-easyinput
			v-model="qq"
			  :input-border="false" 
			  placeholder="请输入QQ"
			  placeholder-style="font-size: 25rpx;color: #333333;" />
		</view>
		<view class="black_1">
			<view class="text1">手机号</view>
			<uni-easyinput
			v-model="mobile"
			  :input-border="false" 
			  placeholder="请输入手机号"
			  placeholder-style="font-size: 25rpx;color: #333333;" />
		</view>
		<view class="submit" @click="showEconomyPay()">提交</view>
		<economyPay ref="economyPay" :success="economyPayUsucess"></economyPay>
	</view>
</template>

<script>
	import economyPay from '@/components/pay/economyPay.vue'
	
	export default {
		components:{
			economyPay
		},
		data() {
			return {
				name:'',
				qq	:'',
				wx	:'',
				mobile:'',
				agent_margin_amount:0,
				password:''
			};
		},
		onLoad() {
			this.api.http.requests('common/webSetting', {}, res => {
				this.agent_margin_amount = res.data.agent_margin_amount
			}, "POST")
		}
		,methods:{
			economyPayUsucess(password){
				this.password= password
				this.submit()
			},
			showEconomyPay(){
				this.$refs.economyPay.open(0,0,this.agent_margin_amount)
			},
			submit(){
				if(!this.wx){
					uni.showToast({
						title:'请输入微信'
					})
					return
				}
				if(!this.name){
					uni.showToast({
						title:'请输入名字'
					})
					return
				}
				if(!this.qq){
					uni.showToast({
						title:'请输入QQ'
					})
					return
				}
				if(!this.mobile){
					uni.showToast({
						title:'请输入手机号'
					})
					return
				}
				var data={
					name:this.name,
					qq:this.qq,
					wx:this.wx,
					mobile:this.mobile,
					password:this.password
				}
				this.api.http.requests('agent/apply', data, res => {
					if(res.code != 200){
						uni.showToast({title:res.msg,icon:'none'})
						return
					}
					uni.showToast({
						title:res.msg,
						success: function () {
						       setTimeout(function () {
						           //要延时执行的代码
						         uni.navigateBack()
						       }, 3000) //延迟时间 
						   }
					})
					
				}, "POST")
			}
		}
	}
</script>

<style lang="scss">

.black_1{
	display: flex;
	padding: 10px;
	border-bottom:  1px solid #ECECEC;
	align-items: center;
	.text1{
		width: 50px;
		font-size: 16px;
		font-weight: 400;
		color: #333333;
	}
}

.submit{
	margin: 80px 20px 10px 20px;
	text-align: center;
	padding: 10px;
	background: #FE903D;
	border-radius: 8px 8px 8px 8px;
	font-size: 35rpx;
	font-weight: bold;
	color: #FFFFFF;
}
</style>
